import logging
import redis


class Config(object):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1/information'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_HOST = '127.0.0.1'
    REDIS_POST = 6379

    SECRET_KEY = 'lian'
    SESSION_TYPE = 'redis'  # 指明绑定的数据库
    # 实例化数据库
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_POST)
    SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
    PERMANENT_SESSION_LIFETIM = 86400  # session 的有效期，单位是秒, 默认为31天


class DevelopmentConfig(Config):
    LOG_LEVEL = logging.DEBUG
    DEBUG = True


class ProductionConfig(Config):
    LOG_LEVEL = logging.WARN    # DATABASE_URI = 'mysql://user@localhost/foo'
    DEBUG = False
